package com.newsvoice.activity;

import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.app.Application;

public class NewsVoiceApplication extends Application {
	// sensible place to declare a log tag for the application
	public static final String LOG_TAG = "myapp";
	public static final String filePrefrences = "setting_preferences";
	// instance
	private static NewsVoiceApplication instance = null;

	// keep references to our global resources
	private static HashMap<String, List<JSONObject>> adaptersCache = new HashMap<String, List<JSONObject>>();
	private static HashMap<String, Integer> offsetCache = new HashMap<String, Integer>();
	
	
	
	public static HashMap<String, Integer> getOffsetCache() {
		
		return offsetCache;
	}

	public static void setOffsetCache(HashMap<String, Integer> offsetCache) {
		NewsVoiceApplication.offsetCache = offsetCache;
	}

	public static HashMap<String, List<JSONObject>> getAdaptersCache() {
		return adaptersCache;
	}

	public static void setAdaptersCache(
			HashMap<String, List<JSONObject>> adaptersCache) {
		NewsVoiceApplication.adaptersCache = adaptersCache;
	}

	/**
	 * Convenient accessor, saves having to call and cast
	 * getApplicationContext()
	 */
	public static synchronized NewsVoiceApplication getInstance() {
		checkInstance();
		return instance;
	}

	private static void checkInstance() {
		if (instance == null)
			throw new IllegalStateException("Application not created yet!");
	}

	@Override
	public void onCreate() {
		super.onCreate();
		// provide an instance for our static accessors
		instance = this;
	}
}
